﻿// Editor is component that shows a field when clicked
define([
    'Xjs/core/util',
    'Xjs/ui/View',
    'Xjs/ui/field/TextField',
    'Xjs/ui/field/DateField'
],
function (util, View) {
    'use strict';

    var type = 'editor',
    Editor = Xjs.getType(type);

    if (Editor) { // It has been already loaded
        return Editor;
    }
    
    Editor = util.define({
        base: View,

        construct: function (conf, parent) {

            Editor.base.constructor.call(this, conf, parent);

        },
        type: type,
        tag: 'div',

        build: function () {
            this.builder.clear();

            if (this.editor) {
                this.builder.addText(this.editor);
            }

            return this.builder;
        },

        onRender: function () {

            this.rendered = true; // Flag it as rendered

            this.callHandlers('onRender'); // Call any handler registered for this event
        }
    });

    Xjs.registerType(Editor);

    return Editor;
});